import React, { Component } from 'react'
import PropTypes from 'prop-types'

class TodoItem extends Component {
    constructor(props) {
        super(props)
        this.handleDelClick = this.handleDelClick.bind(this)
    }
    render() {
        const { content, test } = this.props
        return (
            <div onClick={this.handleDelClick}>{test}-{content}</div>
        )
    }
    handleDelClick() {
        const { handleDelClick, index } = this.props
        handleDelClick(index)
    }
}
TodoItem.propTypes = {
    content: PropTypes.string,
    test: PropTypes.string.isRequired,
    index: PropTypes.number,
    handleDelClick: PropTypes.func
}
TodoItem.defaultProps = {
    test: 'Hello'
}

export default TodoItem